package com.woniuxy.intellihome.mapper;

import com.woniuxy.intellihome.entity.Collect;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口，
 * </p>
 *
 * @author jobob
 * @since 2021-08-11
 */
public interface CollectMapper extends BaseMapper<Collect> {
    //通过用户id和sku_id来删除收藏
    @Delete("delete from m_collect where user_id = #{userId} and sku_id=#{skuId}")
    void delByUserIdWithSkuId(@Param("userId")int userId,@Param("skuId")int skuId);

    //通过用户id获取该用户的收藏表list
    @Select("select * from m_collect where user_id=#{userId}")
    List<Collect> getByUserId(int userId);

    //增加收藏
    @Insert("insert into m_collect (user_id,sku_id,time) values(#{userId},#{skuId},#{time})")
    void addByUserIdWithSkuId(@Param("userId")int userId,@Param("skuId")int skuId,@Param("time")String time);
}
